/**
 * 2016，thor.com，all rights reserved。
 * 
 * Project：		palmmall-core
 * Filename：	SMeterInputConverter.java
 * Created：		2016年8月30日
 * Creator：		wolv
 */
package com.thor.palmmall.rest.patrol.converter;

import org.springframework.core.convert.converter.Converter;

import com.thor.commons.entity.UCN;
import com.thor.commons.util.ConverterUtil;
import com.thor.palmmall.rest.patrol.APatrolBill;
import com.thor.palmmall.spi.device.SDeviceInspect;

/**
 * @author wolv
 *
 */
public class SDeviceInspectConverter implements Converter<APatrolBill, SDeviceInspect> {

	public static SDeviceInspectConverter getInstance() {
		if (instance == null)
			instance = new SDeviceInspectConverter();
		return instance;
	}

	private static SDeviceInspectConverter instance;

	private SDeviceInspectConverter() {
	}

	@Override
	public SDeviceInspect convert(APatrolBill source) {
		if (source == null)
			return null;

		SDeviceInspect target = new SDeviceInspect();
		target.setCategory(UCN.newInstance(source.getCategory()));
		target.setDetails(ConverterUtil.convert(source.getDetails(), SDeviceInspectDetailConverter.getInstance()));
		target.setInspector(UCN.newInstance(source.getPatrolman()));
		target.setInspectTopic(source.getTopic());
		target.setRemark(source.getRemark());
		target.setStore(UCN.newInstance(source.getStore()));
		target.setBillNumber(source.getBillNumber());
		target.setBeginTime(source.getBeginTime());
		target.setUuid(source.getUuid());
		target.setAbortMsg(source.getAbortMsg());

		return target;
	}

}
